package Navigator.Systemer;

import Worker.WorkerDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
//新增员工
@WebServlet(name = "FindWorkerServlet")
public class addWorkerServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        WorkerDao workerDao=new WorkerDao();
        String workerNo=request.getParameter("workerNo");
        String workerName=request.getParameter("workerName");
        String sex=request.getParameter("sex");
        String workPas=request.getParameter("workPas");
        String post=request.getParameter("post");
        int row=workerDao.addWorker(workerNo,workerName,sex,workPas,post);
        if(row>0){
            response.sendRedirect("/SystemerNav/WorkerMangeMent.jsp?workerNo="+workerNo);
        }else {
            response.sendRedirect("/SystemerNav/AddWorker.jsp");
        }
    }
}
